<?php

class Site extends MY_Controller {

    const TIMEOUT = 4;

    public $layout = "layouts/main_base";

    public function __construct() {
        parent::__construct();
        $this->_site_path = config_item('site_path');
    }

    public function index() {
        $this->load->view_part($this->_site_path . '/site/index');
    }

    public function top() {
        $this->load->view($this->_site_path . '/site/top');
    }

    public function left($top = 1) {
        $data['top'] = $top;
        $this->load->view($this->_site_path . '/site/left', $data);
    }

    public function middle() {
        $this->load->view_part($this->_site_path . '/site/middle');
    }

    public function foot() {
        $this->load->view($this->_site_path . '/site/foot');
    }

    public function main() {
        $this->load->view($this->_site_path . '/site/main');
    }

    /**
     * 初始化消息框
     * @param array $content 配置数据
     */
    public function message_box($config) {
        if ($config['redirect_url']) $config['content'] .= ' <strong>' . self::TIMEOUT . '</strong>秒后将自动跳转';
        if (substr($config['content'], 0, 3) !== '<p>') $config['content'] = '<p>' . $config['content'] . '</p>';
        $this->load->view_part($this->_site_path . '/site/messagebox', $config);
    }

    /**
     * 错误页面
     */
    public function error() {
        echo "您好，您无此操作权限。<br/>请联系管理员！！！";
    }

}
